home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 May: Tool Chest / Apple_Developer_CD_Series_May_1994_Tool_Chest.iso / Sample Code / AppsToGo / Kibitz / KibitzWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  16.4 KB  |  635 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        kibitzwindow.c
  5. ** Written by:  Eric Soldan
  6. **
  7. ** Copyright © 1990-1992 Apple Computer, Inc.
  8. ** All rights reserved. */
  9.  
  10.  
  11.  
  12. /*****************************************************************************/
  13.  
  14.  
  15.  
  16. #include "Kibitz.h"                /* Get the Kibitz includes/typedefs, etc.    */
  17. #include "KibitzCommon.h"        /* Get the stuff in common with rez.        */
  18. #include "Kibitz.protos"        /* Get the prototypes for Kibitz.            */
  19.  
  20. #ifndef __ERRORS__
  21. #include <Errors.h>
  22. #endif
  23.  
  24. #ifndef __FONTS__
  25. #include <Fonts.h>
  26. #endif
  27.  
  28. #ifndef __GWLAYERS__
  29. #include <GWLayers.h>
  30. #endif
  31.  
  32. #ifndef __RESOURCES__
  33. #include <Resources.h>
  34. #endif
  35.  
  36. #ifndef __TEXTEDITCONTROL__
  37. #include <TextEditControl.h>
  38. #endif
  39.  
  40. #ifndef __TOOLUTILS__
  41. #include <ToolUtils.h>
  42. #endif
  43.  
  44. #ifndef __UTILITIES__
  45. #include <Utilities.h>
  46. #endif
  47.  
  48.  
  49.  
  50. /*****************************************************************************/
  51.  
  52.  
  53.  
  54. extern short    gPrintPage;                    /* Non-zero means we are printing. */
  55. extern LayerObj    gBoardLayer;
  56. extern short    gClearSquare;
  57.  
  58. CIconHandle        gPieceCIcon[26];
  59.  
  60. static short        gLastPiece[120];
  61. static RgnHandle    gLastColorRgn;
  62.  
  63.  
  64.  
  65. /*****************************************************************************/
  66. /*****************************************************************************/
  67.  
  68.  
  69.  
  70. /* This function adds the application's controls to a window. */
  71.  
  72. #pragma segment Window
  73. OSErr    AppNewWindowControls(FileRecHndl frHndl, WindowPtr window, WindowPtr behind)
  74. {
  75.     WindowPtr        oldPort;
  76.     OSErr            err;
  77.     TEHandle        mssgIn, mssgOut;
  78.     CTEDataHndl        teData;
  79.     ControlHandle    sendMssg, beepOnMove, beepOnMssg, viewCtl;
  80.     Rect            ctlRect, brdrRect, viewRect, destRect;
  81.     ControlHandle    gameSlider, whiteStarts, blackStarts, resign, draw;
  82.     ControlHandle    record, sendSnd;
  83.     Handle            textHndl;
  84.     Boolean            messageDoc;
  85.     short            mode;
  86.     TextStyle        styl;
  87.  
  88.     GetPort(&oldPort);
  89.     SetPort(window);
  90.  
  91.     SetRect(&ctlRect,
  92.             kBoardWidth + 20,
  93.             35,
  94.             rWindowWidth - 20,
  95.             kBoardHalfHeight + kBoardVOffset - 1
  96.     );
  97.  
  98.     brdrRect = viewRect = ctlRect;
  99.     InsetRect(&viewRect, 4, 4);
  100.     destRect = viewRect;
  101.     destRect.right -= 2;
  102.         /* This fixes a TextEdit problem where the view has to be a little
  103.         ** outside the dest on the right, or else characters are clipped.
  104.         */
  105.  
  106.     styl.tsFont = applFont;
  107.     styl.tsSize = 9;
  108.  
  109.     TextFont(styl.tsFont);
  110.     TextSize(styl.tsSize);
  111.  
  112.     CTENew(rTECtl,                /* viewCtl of resID for TextEdit control. */
  113.            true,                    /* Visible.                                  */
  114.            window,                    /* Window to hold TERecord.                  */
  115.            &mssgIn,                    /* Return handle for TERecord.               */
  116.            &ctlRect,                /* Rect for view control.                  */
  117.            &destRect,                /* destRect for TERecord                  */
  118.            &viewRect,                /* viewRect for TERecord                  */
  119.            &brdrRect,                /* Used to frame a border.                  */
  120.            32000,                    /* Maximum TextEdit document length.      */
  121.            cteReadOnly+cteVScroll    /* TERecord is regular read-only.          */
  122.     );
  123.     if (mssgIn)
  124.         TESetStyle((doFont | doSize), &styl, false, mssgIn);
  125.  
  126.     OffsetRect(&ctlRect, 0, kBoardHalfHeight - 38);
  127.  
  128.     messageDoc = false;
  129.     if ((*frHndl)->doc.myColor == kMessageDoc) messageDoc = true;
  130.     if (messageDoc)
  131.         SetRect(&ctlRect, -1, -1, rWindowWidth - 14, rWindowHeight + 1);
  132.             /* When the window is a message document, the whole window is the outbox.
  133.             ** This keep the actual differences between window kinds to a minimum,
  134.             ** while altering the appearance greatly. */
  135.  
  136.     brdrRect = viewRect = ctlRect;
  137.     InsetRect(&viewRect, 4, 4);
  138.     destRect = viewRect;
  139.     destRect.right -= 2;
  140.  
  141.     mode = cteVScroll;
  142.     if (behind == (WindowPtr)-1)
  143.         if (!(*frHndl)->doc.arrangeBoard)
  144.             mode |= cteActive;
  145.     CTENew(rTECtl, true, window, &mssgOut, &ctlRect, &destRect, &viewRect, &brdrRect, 32000, mode);
  146.  
  147.     if (mssgOut) {
  148.         TESetStyle((doFont | doSize), &styl, false, mssgOut);
  149.  
  150.         viewCtl = CTEViewFromTE(mssgOut);
  151.         teData  = (CTEDataHndl)(*viewCtl)->contrlData;
  152.         (*teData)->mode |= cteActive;
  153.             /* Make sure that when a window is activated, the caret blinks.  We need
  154.             ** to do this because the window isn't necessarily opened as the front window.
  155.             ** If we create the TextEdit Control as the active control for a window that
  156.             ** isn't opened as the front window, then we will turn off the caret for
  157.             ** whatever window is the front window.  Al we are doing here is determining
  158.             ** that the message-out TextEdit Control will be the active control when the
  159.             ** window is first brought to the front. */
  160.     
  161.         textHndl = (Handle)(*frHndl)->doc.legalMoves;
  162.         (*frHndl)->doc.legalMoves = (MoveListHndl)CTESwapText(mssgOut, textHndl, nil, false);
  163.             /* AppOpenDocument may have placed some text for the out-box TextEdit
  164.             ** control temporarily in the legalMoves handle.  Move this text into
  165.             ** the out-box TextEdit control. */
  166.     }
  167.  
  168.     sendMssg   = GetNewControl(rSendMessage, window);
  169.     if (sendMssg) HiliteControl(sendMssg, 255);
  170.     beepOnMove = GetNewControl(rMoveNotify, window);
  171.     if (beepOnMove)  HiliteControl(beepOnMove, 255);
  172.     beepOnMssg = GetNewControl(rMssgNotify, window);
  173.     if (beepOnMssg)  HiliteControl(beepOnMssg, 255);
  174.  
  175.     whiteStarts = GetNewControl(rWhiteStarts, window);
  176.     if (whiteStarts) {
  177.         OffsetControl(whiteStarts, -4096, 0);
  178.         SetControlValue(whiteStarts, (*frHndl)->doc.startColor ^ 1);
  179.         ShowControl(whiteStarts);
  180.     }
  181.     blackStarts = GetNewControl(rBlackStarts, window);
  182.     if (blackStarts) {
  183.         OffsetControl(blackStarts, -4096, 0);
  184.         SetControlValue(blackStarts, (*frHndl)->doc.startColor);
  185.         ShowControl(blackStarts);
  186.     }
  187.  
  188.     resign      = GetNewControl(rResign, window);
  189.     draw        = GetNewControl(rDraw, window);
  190.     record  = GetNewControl(rRecordSound, window);
  191.     if (record) HiliteControl(record, 255);
  192.     sendSnd = GetNewControl(rSendSound, window);
  193.     if (sendSnd)   HiliteControl(sendSnd, 255);
  194.  
  195.     gameSlider = BoardSliderNew(window);
  196.  
  197.     (*frHndl)->doc.message[kMessageIn]  = mssgIn;
  198.     (*frHndl)->doc.message[kMessageOut] = mssgOut;
  199.     (*frHndl)->doc.sendMessage = sendMssg;
  200.     (*frHndl)->doc.beepOnMove  = beepOnMove;
  201.     (*frHndl)->doc.beepOnMssg  = beepOnMssg;
  202.     (*frHndl)->doc.gameSlider  = gameSlider;
  203.     (*frHndl)->doc.wbStart[0]  = whiteStarts;
  204.     (*frHndl)->doc.wbStart[1]  = blackStarts;
  205.     (*frHndl)->doc.resign      = resign;
  206.     (*frHndl)->doc.draw        = draw;
  207.     (*frHndl)->doc.record      = record;
  208.     (*frHndl)->doc.sendSnd     = sendSnd;
  209.  
  210.     if (
  211.         (mssgIn) &&
  212.         (mssgOut) &&
  213.         (sendMssg) &&
  214.         (beepOnMove) &&
  215.         (beepOnMssg) &&
  216.         (gameSlider) &&
  217.         (whiteStarts) &&
  218.         (blackStarts) &&
  219.         (resign) &&
  220.         (draw) &&
  221.         (record) &&
  222.         (sendSnd)
  223.     ) {
  224.         if (messageDoc) {
  225.             CTEHide(mssgIn);
  226.             HideControl(sendMssg);
  227.             MoveControl(sendMssg, 0, -4096);    /* So no border is drawn. */
  228.             HideControl(beepOnMove);
  229.             HideControl(beepOnMssg);
  230.             HideControl(gameSlider);
  231.             HideControl(whiteStarts);
  232.             HideControl(blackStarts);
  233.             HideControl(resign);
  234.             HideControl(draw);
  235.             HideControl(record);
  236.             HideControl(sendSnd);
  237.         }
  238.         AdjustGameSlider(frHndl);
  239.         err = noErr;
  240.     }
  241.     else
  242.         err = memFullErr;
  243.  
  244.     SetPort(oldPort);
  245.     return(err);
  246. }
  247.  
  248.  
  249.  
  250. /*****************************************************************************/
  251.  
  252.  
  253.  
  254. #pragma segment Window
  255. void    DrawTime(FileRecHndl frHndl)
  256. {
  257.     WindowPtr        oldPort;
  258.     Rect            clockRect;
  259.     short            clock, i, time[3];
  260.     unsigned long    timeLeft, displayTime;
  261.     Str32            pstr, timestr;
  262.  
  263.     if ((*frHndl)->doc.arrangeBoard) return;
  264.  
  265.     oldPort = SetFilePort(frHndl);
  266.  
  267.     TextMode(srcCopy);
  268.     TextFont(systemFont);
  269.     TextSize(0);
  270.     TextFace(normal);
  271.  
  272.     for (clock = 0; clock < 2; ++clock) {
  273.  
  274.         clockRect = BoardRect();
  275.  
  276.         if (clock == (*frHndl)->doc.invertBoard)
  277.             clockRect.top += 14;
  278.  
  279.         clockRect.left   = clockRect.right + 26;
  280.         clockRect.right  = clockRect.left + 70;
  281.         clockRect.bottom = clockRect.top + 14;
  282.  
  283.         timeLeft = (*frHndl)->doc.timeLeft[clock];
  284.         if (timeLeft == -1) {
  285.             EraseRect(&clockRect);
  286.             continue;
  287.         }
  288.  
  289.         if ((displayTime = (*frHndl)->doc.displayTime[clock]) > timeLeft)
  290.              displayTime = (*frHndl)->doc.displayTime[clock]  = timeLeft;
  291.  
  292.         MoveTo(clockRect.left + 6, clockRect.top + 14);
  293.  
  294.         for (i = 3; i;) {
  295.             displayTime /= 60;
  296.             time[--i] = displayTime % 60;
  297.         }
  298.         timestr[0] = 0;
  299.         for (i = 0; i < 3; ++i) {
  300.             pcpydec(pstr, time[i]);
  301.             if (pstr[0] == 1) pcat(timestr, "\p0");
  302.             pcat(timestr, pstr);
  303.             pcat(timestr, (StringPtr)"\1:\1:\1 " + (i << 1));    /* Append colon or space. */
  304.         }
  305.         DrawString(timestr);
  306.     }
  307.  
  308.     TextMode(srcOr);
  309.     SetPort(oldPort);
  310. }
  311.  
  312.  
  313.  
  314. /*****************************************************************************/
  315.  
  316.  
  317.  
  318. #pragma segment Window
  319. void    ImageBoardLines(short increment, short hOffset, short vOffset)
  320. {
  321.     short    i;
  322.  
  323.     PenNormal();
  324.     PenSize(1, 1);
  325.  
  326.     for (i = 0; i <= 8; i += increment) {
  327.         MoveTo(hOffset, vOffset + kBoardSqSize * i);
  328.         Line(kBoardSqSize * 8, 0);
  329.         MoveTo(hOffset + kBoardSqSize * i, vOffset);
  330.         Line(0, kBoardSqSize * 8);
  331.     }
  332.  
  333.     PenNormal();
  334. }
  335.  
  336.  
  337.  
  338. /*****************************************************************************/
  339.  
  340.  
  341.  
  342. /* Image the document into the current port. */
  343.  
  344. #pragma segment Window
  345. void    ImageDocument(FileRecHndl frHndl, Boolean justBoard)
  346. {
  347.     short            r, c, rr, cc, piece, pieceIconID, fnum, i;
  348.     short            gameIndex, lastFrom, lastTo, square, ss, hOffset, vOffset;
  349.     Boolean            toWindow, invertBoard, messageDoc;
  350.     LayerObj        windowLayer;
  351.     Rect            sqRect, theInk, boardRect;
  352.     GameListHndl    gameMoves;
  353.     WindowPtr        curPort;
  354.     TEHandle        te;
  355.     Point            pt;
  356.     RgnHandle        colorRgn, testRgn;
  357.     static short    teOffset;
  358.  
  359.     GetPort(&curPort);
  360.  
  361.     toWindow = (curPort == (*frHndl)->fileState.window);
  362.     if (!toWindow) gClearSquare = 0;
  363.  
  364.     messageDoc = false;
  365.     if ((*frHndl)->doc.myColor == kMessageDoc) messageDoc = true;
  366.  
  367.     colorRgn = testRgn = nil;
  368.  
  369.     hOffset = kBoardHOffset;
  370.     vOffset = kBoardVOffset;
  371.     if (gPrintPage > 0) {
  372.         theInk = curPort->portRect;
  373.         GetFNum("\pTimes", &fnum);
  374.         TextFont(fnum);
  375.         TextSize(12);
  376.         TextFace(normal);
  377.         hOffset = theInk.right - 10 - kBoardWidth;
  378.         vOffset = 10;
  379.         if (messageDoc) {
  380.             if (gPrintPage == 1) teOffset = 0;
  381.             te = (*frHndl)->doc.message[kMessageOut];
  382.             InsetRect(&theInk, 4, 4);
  383.             CTEPrint(te, &teOffset, &theInk);
  384.             if (teOffset == -1) gPrintPage = 0;
  385.             return;
  386.         }
  387.         if (curPort->portBits.rowBytes & 0x8000)
  388.             RectRgn(colorRgn = NewRgn(), &theInk);
  389.                 /* Print the board in grayscale or color if user has so chosen. */
  390.     }
  391.     else {
  392.         SetRectRgn(curPort->clipRgn, -30000, -30000, 30000, 30000);
  393.  
  394.         if (!messageDoc) {
  395.             if (!gPrintPage) ImageBoardLines(8, hOffset, vOffset);
  396.  
  397.             colorRgn = ScreenDepthRegion(8);        /* Screen of 8-bit or greater get color icon. */
  398.             pt.h = pt.v = 0;
  399.             GlobalToLocal(&pt);
  400.             OffsetRgn(colorRgn, pt.h, pt.v);        /* Localize the area that gets color icons. */
  401.  
  402.             if (!gPrintPage) SetLayerWorld(gBoardLayer);
  403.         }
  404.     }
  405.  
  406.     if (!colorRgn) colorRgn = NewRgn();
  407.     if (!testRgn)  testRgn  = NewRgn();
  408.  
  409.     if (!gLastColorRgn) gLastColorRgn = NewRgn();
  410.     if ((gPrintPage) || (!EqualRgn(colorRgn, gLastColorRgn)))
  411.         for (i = 0; i < 120; ++i) gLastPiece[i] = 0;
  412.             /* If printing, exporting a board, or if color region has changed, redraw all squares. */
  413.     CopyRgn(colorRgn, gLastColorRgn);
  414.  
  415.     invertBoard = (*frHndl)->doc.invertBoard;
  416.     lastFrom = lastTo = 0;
  417.     gameIndex = (*frHndl)->doc.gameIndex;
  418.     gameMoves = (*frHndl)->doc.gameMoves;
  419.     if (gameIndex) {
  420.         lastFrom = (**gameMoves)[gameIndex - 1].moveFrom;
  421.         lastTo   = (**gameMoves)[gameIndex - 1].moveTo;
  422.         if (!lastFrom) {
  423.             if (gameIndex > 1) {
  424.                 lastFrom = (**gameMoves)[gameIndex - 2].moveFrom;
  425.                 lastTo   = (**gameMoves)[gameIndex - 2].moveTo;
  426.             }
  427.         }
  428.     }
  429.  
  430.     if (gPrintPage < 2) {        /* If not printing, or printing first page... */
  431.         if (!messageDoc) {
  432.             for (r = 0; r < 8; ++r) {
  433.                 if (gClearSquare) r = (gClearSquare - START_IBNDS) / 10;
  434.  
  435.                 for (c = 0; c < 8; ++c) {
  436.                     if (gClearSquare) c = gClearSquare - START_IBNDS - 10 * r;
  437.                 
  438.                     piece = (*frHndl)->doc.theBoard[square = START_IBNDS + 10 * r + c];
  439.                     if (gClearSquare) piece = EMPTY;
  440.                     pieceIconID = piece + KING;
  441.     
  442.                     rr = r;
  443.                     cc = c;
  444.                     if (invertBoard) {
  445.                         rr = 7 - r;
  446.                         cc = 7 - c;
  447.                     }
  448.                     ss = START_IBNDS + 10 * rr + cc;
  449.  
  450.                     if ((rr + cc) & 0x01) pieceIconID += 13;
  451.  
  452.                     if (!gPieceCIcon[pieceIconID])
  453.                         gPieceCIcon[pieceIconID] = ReadCIcon(pieceIconID + 257);
  454.  
  455.                     sqRect.top    = vOffset + kBoardSqSize * rr + 1;
  456.                     sqRect.left   = hOffset + kBoardSqSize * cc + 1;
  457.                     sqRect.bottom = sqRect.top  + 32;
  458.                     sqRect.right  = sqRect.left + 32;
  459.  
  460.                     if (gLastPiece[ss] != pieceIconID + 257) {
  461.                         gLastPiece[ss] = pieceIconID + 257;
  462.                         if (!RectInRgn(&sqRect, colorRgn))        /* If 1-bit, draw b/w icon. */
  463.                             DrawCIconByDepth(gPieceCIcon[pieceIconID], sqRect, 1, false);
  464.                         else {        /* Draw some combo of color and b/w icon. */
  465.                             RectRgn(testRgn, &sqRect);
  466.                             SectRgn(testRgn, colorRgn, testRgn);
  467.                             for (;;) {
  468.                                 if ((*testRgn)->rgnSize == 10) {
  469.                                     if (EqualRect(&((*testRgn)->rgnBBox), &sqRect)) {
  470.                                         DrawCIconByDepth(gPieceCIcon[pieceIconID], sqRect, 8, false);
  471.                                         break;            /* Icon completely on color monitor. */
  472.                                     }
  473.                                 }
  474.                                 DrawCIconByDepth(gPieceCIcon[pieceIconID], sqRect, 1, false);
  475.                                     /* Icon is across two monitors, so first draw it b/w. */
  476.                                 SetClip(testRgn);
  477.                                 DrawCIconByDepth(gPieceCIcon[pieceIconID], sqRect, 8, false);
  478.                                     /* Then redraw the color portion. */
  479.                                 SetRectRgn(testRgn, -30000, -30000, 30000, 30000);
  480.                                 SetClip(testRgn);
  481.                                 break;
  482.                             }
  483.                         }
  484.                     }
  485.  
  486.                     if (!gPrintPage) {
  487.                         if ((square == lastFrom) || (square == lastTo)) {
  488.                             FrameRect(&sqRect);
  489.                             gLastPiece[ss] = 0;
  490.                         }
  491.                     }
  492.  
  493.                     if (gClearSquare) break;
  494.                 }
  495.                 if (gClearSquare) break;
  496.             }
  497.         }
  498.     }
  499.  
  500.     DisposeRgn(colorRgn);
  501.     DisposeRgn(testRgn);
  502.  
  503.     if (!gPrintPage) {
  504.         if (!messageDoc)
  505.             if (!gPrintPage)
  506.                 ResetLayerWorld(gBoardLayer);
  507.         if (toWindow) {
  508.             if (!gClearSquare) {
  509.                 if (!messageDoc) {
  510.                     if (!NewLayer(&windowLayer, nil, nil, curPort, 8, 0)) {
  511.                         InsertLayer(gBoardLayer, windowLayer, 1);
  512.                         boardRect = BoardRect();
  513.                         (*windowLayer)->dstRect = boardRect;
  514.                         InvalLayer(windowLayer, boardRect, false);
  515.                         UpdateLayer(windowLayer);
  516.                         DisposeLayer(windowLayer);
  517.                     }
  518.                 }
  519.             }
  520.         }
  521.     }            
  522.  
  523.     if (gPrintPage) {                /* If printing... */
  524.         if (gPrintPage == 1)        /* If printing page 1... */
  525.             ImageBoardLines(1, hOffset, vOffset);
  526.         ImageMoveList(frHndl, theInk, hOffset);
  527.         return;
  528.     }
  529.  
  530.     if (!justBoard) {
  531.         SetOrigin((*frHndl)->doc.arrangeBoard * 4096, 0);
  532.         if (!messageDoc) UpdateGameStatus(frHndl);
  533.         DoDrawControls(curPort, false);
  534.         if (!messageDoc) {
  535.             OutlineControl((*frHndl)->doc.sendMessage);
  536.             DrawTime(frHndl);
  537.             DrawPalette(frHndl);
  538.         }
  539.         SetOrigin(0, 0);
  540.     }
  541. }
  542.  
  543.  
  544.  
  545. /*****************************************************************************/
  546.  
  547.  
  548.  
  549. #pragma segment Window
  550. void    ImageMoveList(FileRecHndl frHndl, Rect theInk, short hOffset)
  551. {
  552.     short    gameIndex, numGameMoves, printMoveNum, colsPerPage, colHeight;
  553.     short    pageNum, colNum, colVOffset, numMovePairs, colEndMove, hloc, vloc;
  554.     Str255    pstr;
  555.  
  556.     gameIndex    = (*frHndl)->doc.gameIndex;
  557.     numGameMoves = (*frHndl)->doc.numGameMoves;
  558.     printMoveNum = (*frHndl)->doc.startColor;
  559.     colsPerPage  = (theInk.right  - theInk.left) / 180;
  560.     colHeight    = (theInk.bottom - theInk.top) - 2 * kBoardHOffset;
  561.  
  562.     for (pageNum = 1; pageNum <= gPrintPage; ++pageNum) {
  563.  
  564.         for (colNum = 1; colNum <= colsPerPage; ++colNum) {
  565.  
  566.             hloc = colNum * 180 - 120;
  567.  
  568.             colVOffset = 0;
  569.             if (pageNum == 1) {
  570.                 if (colNum == 1) colVOffset = (3 * 20);
  571.                 if (hloc + 130 >= hOffset)
  572.                     for (; colVOffset < (kBoardHeight + 20 + kBoardVOffset); colVOffset += 20) {};
  573.                         /* Start this column below the board on 20-pixel boundary. */
  574.             }
  575.  
  576.             numMovePairs = (colHeight - colVOffset) / 20;
  577.             colEndMove   = printMoveNum + 2 * numMovePairs;
  578.  
  579.             if (pageNum == gPrintPage) {
  580.  
  581.                 if ((pageNum == 1) && (colNum == 1)) {
  582.                     MoveTo(hloc, theInk.top + 20);
  583.                     pcpy(pstr, (*frHndl)->fileState.fss.name);
  584.                     TextFace(bold + underline);
  585.                     DrawString(pstr);
  586.                     TextFace(normal);
  587.                 }
  588.  
  589.                 for (; printMoveNum < colEndMove; ++printMoveNum) {
  590.  
  591.                     RepositionBoard(frHndl, printMoveNum, false);
  592.  
  593.                     if (printMoveNum >= numGameMoves) {
  594.                         gPrintPage = 0;
  595.                         RepositionBoard(frHndl, gameIndex, false);
  596.                         return;
  597.                     }
  598.  
  599.                     vloc = theInk.top + colVOffset + 20;
  600.  
  601.                     if (!(printMoveNum & 0x01)) {
  602.                         pcpydec(pstr, printMoveNum / 2 + 1);
  603.                         MoveTo(hloc - 16 - StringWidth(pstr), vloc);
  604.                         DrawString(pstr);
  605.                         DrawString("\p)");
  606.                         MoveTo(hloc, vloc);
  607.                     }
  608.                     else {
  609.                         MoveTo(hloc + 40, vloc);
  610.                         MoveTo(hloc + 40 + 12, vloc);
  611.                         colVOffset += 20;
  612.                     }
  613.  
  614.                     if (Algebraic(frHndl, printMoveNum, gameIndex, pstr))
  615.                         TextFace(underline);
  616.  
  617.                     DrawString(pstr);
  618.                     TextFace(normal);
  619.                 }
  620.             }
  621.  
  622.             if ((printMoveNum = colEndMove) >= numGameMoves) {
  623.                 gPrintPage = 0;
  624.                 RepositionBoard(frHndl, gameIndex, false);
  625.                 return;
  626.             }
  627.         }
  628.     }
  629.  
  630.     RepositionBoard(frHndl, gameIndex, false);
  631. }
  632.  
  633.  
  634.  
  635.